<?php

namespace common\models\hospital;

use Yii;

/**
 * This is the model class for table "jg_patient_expense".
 *
 * @property int $id
 * @property int $business_type 业务类型
 * @property string $card_id 卡号
 * @property string $patient_name 患者姓名
 * @property string $doctor_name 医生姓名
 * @property int $section 科室
 * @property string $drug 药品名称
 * @property string $unit 药品单位
 * @property int $count 数量
 * @property double $sales_money 销价金额
 * @property double $price 售价
 * @property double $discounted_money 折后金额
 * @property double $buy_money 进价金额
 * @property double $difference_money 进销差额
 * @property string $money_name 费用名称
 * @property string $event_time 发生时间
 * @property string $entry_time 录入时间
 * @property string $user_name 操作员
 * @property int $user_id 操作员id
 * @property int $total_id 数据关联合计表id
 * @property int $created_at 创建时间
 * @property int $updated_at 更新时间
 * @property string $total_md5 合计md5 加密
 * @property int serial_no 奕远id
 * @property int type 0-门诊 1-住院
 * @property int day 天的时间戳
 */
class Expense extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */

    public static $pix = '';

    public static function tableName()
    {
        return '{{%patient_expense_'.self::$pix.'}}';
    }

    public static function primaryKey()
    {
        return ['id'];
    }

    public static function getDb()
    {
        return Yii::$app->db3;
    }

    const TYPE_OUTPATIENT = 1; // 门诊
    const TYPE_IN_HOSPITAL = 2; // 住院

    public static $businessType = [
        self::TYPE_OUTPATIENT => '门诊',
        self::TYPE_IN_HOSPITAL => '住院',
    ];

    //
    public static $drugProject = [
        'wz' => [
            '308准分子激光',
            '中药药浴治疗',
        ],
        'sz' => [
            '308准分子激光',
            '中药药浴治疗',
            '中药熏蒸治疗',
        ],
        'nt' => [
            '中药药浴治疗',
            '308准分子激光'
        ],
        'nb' => [
            '308准分子激光',
            '中药药浴治疗',
            '中药熏蒸治疗',
        ],
    ];

    /**
     * 特殊治疗项目名统一
     * @var array
     */
    public static $drugSpecial = [
        'nb' => [
            '美国进口308准分子激光治疗' => '308准分子激光',
            '局部介入治疗' => '局部介入增敏治疗',
            '局部介入治疗加组' => '局部介入增敏治疗',
            '311窄谱UVB半仓光疗' => '311窄谱UVB半身光疗',
            '311窄谱UVB全仓光疗' => '311窄谱UVB全身光疗',
            '二氧化碳激光治疗' => '点阵激光治疗',
        ],
        'gz' => [
            '308' => '美国308准分子激光',
        ],
        'cs' => [
            '电离子点痣(大)' => '电离子点痣-大',
            '311nm窄谱紫外线(半身)' => '311nm窄谱紫外线-半身',
            '黑色素细胞种植治疗(小面积)' => '黑色素细胞种植治疗-小面积',
            '中药全身药浴治疗(青少年、少儿)' => '中药全身药浴治疗-青少年少儿',
            '311nm窄谱紫外线(全身)' => '311nm窄谱紫外线-全身',
            '中药全身药浴治疗(幼儿)' => '中药全身药浴治疗-幼儿',
            '纳米促黑(加收部位)' => '纳米促黑-加收部位',
            '纳米微晶促黑(加收部位)' => '纳米微晶促黑-加收部位',
            '电离子点痣(小)' => '电离子点痣-小',
            '电离子去汗管瘤(大)' => '电离子去汗管瘤-大',
        ]
    ];


    /**
     * {@inheritdoc}
     */
//    public function rules()
//    {
//        return [
//            [['business_type', 'patient_name', 'doctor_name', 'section', 'drug', 'unit', 'count', 'sales_money', 'price', 'discounted_money', 'buy_money', 'difference_money', 'money_name', 'event_time', 'user_name', 'user_id', 'total_id', 'created_at', 'updated_at'], 'required'],
//            [['business_type', 'section', 'count', 'user_id', 'total_id', 'created_at', 'updated_at'], 'integer'],
//            [['sales_money', 'price', 'discounted_money', 'buy_money', 'difference_money', 'money_name'], 'number'],
//            [['event_time'], 'safe'],
//            [['patient_name', 'doctor_name', 'user_name'], 'string', 'max' => 50],
//            [['drug'], 'string', 'max' => 100],
//            [['unit'], 'string', 'max' => 20],
//        ];
//    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'business_type' => 'Business Type',
            'card_id' => 'Card Id',
            'patient_name' => 'Patient Name',
            'doctor_name' => 'Doctor Name',
            'section' => 'Section',
            'drug' => 'Drug',
            'unit' => 'Unit',
            'count' => 'Count',
            'sales_money' => 'Sales Money',
            'price' => 'Price',
            'discounted_money' => 'Discounted Money',
            'puy_money' => 'Puy Money',
            'difference_money' => 'Difference Money',
            'money_name' => 'Money Name',
            'event_time' => 'Event Time',
            'user_name' => 'User Name',
            'user_id' => 'User ID',
            'total_id' => 'Total ID',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }
}
